package cn.melon.mod.sc;

import org.json.JSONException;
import org.json.JSONObject;

public class ScInfo {

    private String classTerm;        // 课程学期
    private String classNumber;      // 课程代号
    private String className;        // 课程名称
    private String classTeacher;     // 课程教师
    private String classroom;        // 上课地点
    private String classTime;        // 上课时间
    
    

    public static ScInfo toInfo(JSONObject jInfo) throws JSONException {

        ScInfo scInfo = new ScInfo();
        scInfo.setClassTerm(jInfo.getString("classTerm"));
        scInfo.setClassNumber(jInfo.getString("classNumber"));
        scInfo.setClassName(jInfo.getString("className"));
        scInfo.setClassTeacher(jInfo.getString("classTeacher"));
        scInfo.setClassroom(jInfo.getString("classroom"));
        scInfo.setClassTime(jInfo.getString("classTime"));

        return scInfo;
    }

    public JSONObject toJSON() throws JSONException {
        JSONObject jInfo = new JSONObject();
        jInfo.put("classTerm", getClassTerm());
        jInfo.put("classNumber", getClassNumber());
        jInfo.put("className", getClassName());
        jInfo.put("classTeacher", getClassTeacher());
        jInfo.put("classroom", getClassroom());
        jInfo.put("classTime", getClassTime());

        return jInfo;
    }

    public ScInfo() {

    }

    public ScInfo(String classTerm, String classNumber, String className, String classTeacher, String classroom,
            String classTime) {
        this.classTerm = classTerm;
        this.classNumber = classNumber;
        this.className = className;
        this.classTeacher = classTeacher;
        this.classroom = classroom;
        this.classTime = classTime;

    }

    public String getClassNumber() {
        return classNumber;
    }

    public void setClassNumber(String classNumber) {
        this.classNumber = classNumber;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassTeacher() {
        return classTeacher;
    }

    public void setClassTeacher(String classTeacher) {
        this.classTeacher = classTeacher;
    }

    public String getClassroom() {
        return classroom;
    }

    public void setClassroom(String classroom) {
        this.classroom = classroom;
    }

    public String getClassTime() {
        return classTime;
    }

    public void setClassTime(String classTime) {
        this.classTime = classTime;
    }

    public String getClassTerm() {
        return classTerm;
    }

    public void setClassTerm(String classTerm) {
        this.classTerm = classTerm;
    }

    public void setClassByJsonObj(JSONObject jsonObject) {
        try {
            this.setClassTerm(jsonObject.getString("classTerm"));
            this.setClassNumber(jsonObject.getString("classNumber"));
            this.setClassName(jsonObject.getString("className"));
            this.setClassTeacher(jsonObject.getString("classTeacher"));
            this.setClassroom(jsonObject.getString("classroom"));
            this.setClassTime(jsonObject.getString("classTime"));

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public JSONObject toJsonObject() {
        JSONObject jsonObject = new JSONObject();

        try {
            jsonObject.put("classTerm", this.getClassTerm());
            jsonObject.put("classNumber", this.getClassNumber());
            jsonObject.put("className", this.getClassName());
            jsonObject.put("classTeacher", this.getClassTeacher());
            jsonObject.put("classroom", this.getClassroom());
            jsonObject.put("classTime", this.getClassTime());

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return jsonObject;
    }

}
